.global _ThisCall
.text
;/*
;     void    *function  -> the class member function address
;     void    *this      -> the class 'this' pointer
;     uint32_t argCount  -> the total # of arguments in the array
;     uint32_t argList[] -> pointer to an array of arguments
;                           The first argument should be first in the array
;                           eg: {arg1, arg2, arg3}
;*/
;###############################################################
;# uint32_t  __cdecl thisCall(  void *function,         0x08   #
;#                              void *this,             0x0C   #
;#                              uint32_t argCount,      0x10   #
;#                              uint32_t argList[]);    0x14   #
;###############################################################
_ThisCall:      push        %ebp
                mov         %esp, %ebp
                movl        0x10(%ebp), %ecx;   # ecx = argCount
                movl        0x14(%ebp), %edx;   # edx = argList
thiscallloop:   cmpl        $0x00, %ecx;        # 
                jz          thiscallend;        # Loop till ecx is 0
                movl        (%edx), %eax;       #    eax = *argList
                push        %eax;               #    push eax on the stack
                dec         %ecx;               # ecx -= 1
                addl        $0x04, %edx;        # argList += 1
                jmp         thiscallloop;       # ^ loop
thiscallend:    movl        0x0C(%ebp), %ecx;   # ecx = this
                movl        0x08(%ebp), %edx;   # edx = function
                call        *%edx;              # Call the function and return
                leave;
                ret;
